local key = KEYS[1]
local currentUserId = ARGV[1]

local get = redis.call('get', key)

if not get or get == '' then
    redis.call('set', key, currentUserId)
    redis.call('expire', key, 30)
    return currentUserId
elseif get == currentUserId then
    redis.call('expire', key, 30)
    return currentUserId
else
    return get
end
